package com.cloud.lan.api.manage;

import com.cloud.lan.api.dto.req.LanSmsSendReq;
import com.cloud.lan.entity.base.BaseResponse;
import com.cloud.lan.service.ILanSmsSendService;
import com.cloud.lan.service.tx.wx.WxCService;
import com.cloud.lan.service.tx.wx.model.WxUrlLinkReq;
import com.cloud.lan.service.tx.wx.model.WxUrlLinkRes;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by zhouquan on 2022/4/14.
 */
@RestController
@RequestMapping(value = {"/v1/manage/sms/send"}, method = {RequestMethod.GET, RequestMethod.POST}, produces = {"application/json"})
public class SmsSendMangeApi {

    @Autowired
    private ILanSmsSendService iLanSmsSendService;

    @Autowired
    private WxCService wxCService;


    @RequestMapping("submitTask")
    public BaseResponse<Object> submitTask(@RequestBody LanSmsSendReq sendReq){
        return iLanSmsSendService.submitTask(sendReq);
    }

    @RequestMapping("createUrlLink")
    public BaseResponse<Object> createUrlLink(WxUrlLinkReq linkReq){
        WxUrlLinkRes linkRes = wxCService.createUrlLink(linkReq);
        if(StringUtils.isBlank(linkRes.getUrl_link())){
            return BaseResponse.success(linkRes.getErrmsg());
        }else{
            return BaseResponse.success(linkRes.getUrl_link());
        }

    }

}
